import { storeBindingsBehavior } from "mobx-miniprogram-bindings";
import base from "@src/store/base";

Component({
  behaviors: [storeBindingsBehavior],
  storeBindings: [{
    store: base,
    fields: ['isiPhoneX', 'themeColor', 'themeTitleColor']
  }],
  /**
   * 组件的属性列表
   */
  properties: {
    //是否隐藏底下按钮
    hiddenbtn: {
      type: Boolean,
      value: false
    },
    showBottomNobutton: {
      type: Boolean,
      value: false
    },

    //显示头部
    showHeader: {
      type: Boolean,
      value: true
    },

    contentHeight: {
      type: Number,
      value: 20
    },
    //是否显示了组件用于监听高度
    showComponents: {
      type: Boolean,
      value: false
    },





  },
  options: {
    multipleSlots: true,
    addGlobalClass: true
  },
  lifetimes: {

  },
  observers: {
    'showComponents': function () {

      if (this.data.showComponents) {
        const self = this;
        let query = wx.createSelectorQuery().in(this);
        query.select('.content').boundingClientRect()
        query.selectViewport().scrollOffset()
        query.exec((res) => {

          //向父组件发出事件
          this.triggerEvent('minitorHeight', res[0].height)

          // self.setData({
          //   contentHeight: res[0].height
          // })
          // // console.log(res[0].height)
          // let a = res[0].height
          // this.triggerEvent('getHeader',a)
        })
      }
    }


  },



  /**
   * 组件的方法列表
   */
  methods: {
    //设置hidden为true
    setHiddenTrue() {
      this.triggerEvent('setHiddentrue', true);
    },
    hideBuyView: function (e) {// 隐藏商品弹框

      if (e.target.dataset.target == 'self')
        this.triggerEvent('setHiddentrue', true);
    },
    noHideBuyView() {

    }


    //设置hidden为false
    // setHiddenFalse() {
    //   this.setData({
    //     hideappdetaile:false
    //   })
    // },
  }
})
